package com.carefree.common.exception;

import com.carefree.common.emus.StatusCodeEnum;
import lombok.Data;


/**
 * 自定义异常处理
 *
 * @author tengbin
 */
@Data
public class BusinessException extends RuntimeException {
    private final int code;

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(StatusCodeEnum statusCodeEnum) {
        super(statusCodeEnum.getMessage());
        this.code = statusCodeEnum.getCode();
    }

    public BusinessException(StatusCodeEnum statusCodeEnum, String message) {
        super(message);
        this.code = statusCodeEnum.getCode();
    }

    public int getCode() {
        return code;
    }
}
